from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *

a = QApplication([])   
class my2(QMainWindow):
    def __init__(self):
        super().__init__()
    def paintEvent(self,e):        
        for i in range(100):
            for j in range(100):
                img.setPixelColor(QPoint(i, j), Qt.red)
        painter = QPainter (self);
        painter.drawImage(0, 0, img)

img = QPixmap(QSize(100, 100)).toImage()

w2 = my2()
w2.show()
a.exec_()